#pragma once

///////////////////////////
//						 //
//  Frustum Definition   //
//						 //
///////////////////////////

class Frustum
{
public:
	enum Side {Near, Far, Top, Right, Bottom, Left, NumPlanes};

	Plane mp_lanes[NumPlanes];	// planes of the frusum in camera space
	Vector3 m_nearClip[4];		// verts of the near clip plane in camera space
	Vector3 m_farClip[4];		// verts of the far clip plane in camera space

	float m_fov;				// field of view in radians
	float m_aspect;				// aspect ratio - width divided by height
	float m_near;				// near clipping distance
	float m_far;				// far clipping distance

public:
	Frustum();
	//Frustum(Frustum& f)
	//{
	//	memcpy(m_Planes, f.m_Planes, sizeof(Plane) * NumPlanes);
	//	memcpy(m_NearClip, f.m_NearClip, sizeof(Vector3) * 4);
	//	memcpy(m_FarClip, f.m_FarClip, sizeof(Vector3) * 4);

	//	m_Fov = f.m_Fov;
	//	m_Aspect = f.m_Aspect;
	//	m_Near = f.m_Near;
	//	m_Far = f.m_Far;
	//}

	bool Inside(const Vector3& Vector2) const;
	bool Inside(const Vector3& Vector2, const float radius) const;
	const Plane& Get(Side side) {return mp_lanes[side];}
	void SetFOV(float fov) {m_fov=fov; Init(m_fov, m_aspect, m_near, m_far);}
	void SetAspect(float aspect) {m_aspect=aspect; Init(m_fov, m_aspect, m_near, m_far); }
	void SetNear(float nearClip) {m_near=nearClip; Init(m_fov, m_aspect, m_near, m_far); }
	void SetFar(float farClip) {m_far=farClip; Init(m_fov, m_aspect, m_near, m_far); }
	void Init(const float fov, const float aspect, const float near, const float far);

	void Render();
};